#!/bin/env sh

# bar
pkill polybar
~/.config/polybar/launch.sh
(xdo id -m -N Polybar && polybar-msg cmd hide)&

#只在开机时执行一次脚本
# up_time=$(uptime -p)
# number=$(echo $up_time | awk '{print $2}')
# formation=$(echo $up_time | awk '{print $3}')
# if [ $number -ne 0 ]; then
#   exit 0
# fi
# 若xcape已启动则退出脚本
if pgrep xcape; then
  exit 0
fi

# monitor
if xrandr | grep "HDMI-0 connected"; then
  xrandr --output DP-4 --off
  xrandr --output HDMI-0 --primary --mode 1920x1080 --rate 144.0
fi

# warpaper
# feh --randomize --bg-fill ~/.config/xmonad/background
feh --bg-fill ~/.config/xmonad/background/wallhaven-kxj3l1_1920x1080.png

# network wifi
# pkill nm-applet
# nm-applet &

# power management
#pkill xfce4-power-manager
#xfce4-power-manager &

# input method
fcitx &

# 权限
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &

# 通知
dunst &

# voice
# pkill volumeicon
# volumeicon &

# blueberry-tray &

# 护眼
if ! (pgrep redshift); then
	redshift -l 29.0:114.5 &
fi
#交换ctrl和caps
# setxkbmap -option ctrl:swapcaps
# setxkbmap -option ctrl:nocaps
# 将caps映射为ctrl
[ -f "$HOME/.Xmodmap" ] && xmodmap "$HOME/.Xmodmap"
# 将按一下caps映射为esc
xcape -e 'Control_L=Escape'
xcape -e 'Shift_R=BackSpace'
xcape -e 'Alt_L=Left'
xcape -e 'Alt_R=Right'
xcape -e 'Control_R=Down'

# 熄屏30min
xset dpms 1800 0 0

#锁屏
xautolock -time 25 -locker "betterlockscreen -l"
